<?php

/**
 * This is the model class for table "wp_pribadi".
 *
 * The followings are the available columns in table 'wp_pribadi':
 * @property string $npwpd_pribadi
 * @property string $nomor_induk
 * @property string $no_telepon
 * @property string $nomor_kk
 * @property string $tanggal_kk
 * @property string $pekerjaan_usaha
 * @property string $nama_instansi
 * @property string $alamat_instansi
 * @property string $status_aktif
 * @property string $tanggal
 *
 * The followings are the available model relations:
 * @property PemilikWp $nomorInduk
 */
class WpPribadi extends CActiveRecord {

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'wp_pribadi';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('npwpd_pribadi', 'required'),
            array('npwpd_pribadi, nomor_induk, no_telepon', 'length', 'max' => 20),
            array('nomor_kk', 'length', 'max' => 30),
            array('pekerjaan_usaha', 'length', 'max' => 35),
            array('nama_instansi', 'length', 'max' => 50),
            array('alamat_instansi', 'length', 'max' => 75),
            array('status_aktif', 'length', 'max' => 2),
            array('tanggal_kk, tanggal', 'safe'),
            // The following rule is used by search().
            // @todo Please remove those attributes that should not be searched.
            array('npwpd_pribadi, nomor_induk, no_telepon, nomor_kk, tanggal_kk, pekerjaan_usaha, nama_instansi, alamat_instansi, status_aktif, tanggal', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'nomorInduk' => array(self::BELONGS_TO, 'PemilikWp', 'nomor_induk'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'npwpd_pribadi' => 'Npwpd Pribadi',
            'nomor_induk' => 'Nomor Induk',
            'no_telepon' => 'No Telepon',
            'nomor_kk' => 'Nomor Kk',
            'tanggal_kk' => 'Tanggal Kk',
            'pekerjaan_usaha' => 'Pekerjaan Usaha',
            'nama_instansi' => 'Nama Instansi',
            'alamat_instansi' => 'Alamat Instansi',
            'status_aktif' => 'Status Aktif',
            'tanggal' => 'Tanggal',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     *
     * Typical usecase:
     * - Initialize the model fields with values from filter form.
     * - Execute this method to get CActiveDataProvider instance which will filter
     * models according to data in model fields.
     * - Pass data provider to CGridView, CListView or any similar widget.
     *
     * @return CActiveDataProvider the data provider that can return the models
     * based on the search/filter conditions.
     */
    public function search() {
        // @todo Please modify the following code to remove attributes that should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('npwpd_pribadi', $this->npwpd_pribadi, true);
        $criteria->compare('nomor_induk', $this->nomor_induk, true);
        $criteria->compare('no_telepon', $this->no_telepon, true);
        $criteria->compare('nomor_kk', $this->nomor_kk, true);
        $criteria->compare('tanggal_kk', $this->tanggal_kk, true);
        $criteria->compare('pekerjaan_usaha', $this->pekerjaan_usaha, true);
        $criteria->compare('nama_instansi', $this->nama_instansi, true);
        $criteria->compare('alamat_instansi', $this->alamat_instansi, true);
        $criteria->compare('status_aktif', $this->status_aktif, true);
        $criteria->compare('tanggal', $this->tanggal, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }

    /**
     * Returns the static model of the specified AR class.
     * Please note that you should have this exact method in all your CActiveRecord descendants!
     * @param string $className active record class name.
     * @return WpPribadi the static model class
     */
    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

}

?>